<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>好好学习</title>
<script type="text/javascript">
 function test(){ 
	 var xmlhttp=new XMLHttpRequest();
	 xmlhttp.open("post","ajaxServlet",true);
	 xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	 xmlhttp.send("username=zhangsan&pwd=123456");
	 xmlhttp.onreadystatechange=function(){
		 console.log(xmlhttp.readyState);
		 document.getElementById("list").innerHTML=xmlhttp.responseText;
	 }
 }
 function test2(){
	 var xmlhttp=new XMLHttpRequest();
	 xmlhttp.open("post","SearchServlet",true);
	 xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	 var title=document.getElementById("_src").value;
	  xmlhttp.send("title="+title);
	  xmlhttp.onreadystatechange=function(){
		  console.log(xmlhttp.responseText);
		  document.getElementById("list2").innerHTML=xmlhttp.responseText;
	  }
	 }
 function test3(str){
	  var title=document.getElementById("bd");
	 title.onclick=function(){
    document.getElementById("_src").value=str;
	 } 
 }
</script>
<style type="text/css">
ul{
 text-decoration: none;
 list-style: none;
}
</style>
</head>
<body>
<input type="button" value="提交" id="but" onclick="test()"/>
<div id="list"></div>
<div>
<ul>
<li><input type="text" name="search" id="_src" onkeyup="test2()" value=""> 搜索</li>
</ul>
<ul id="list2">
</ul>
</div>
</body>
</html>